//
//  SEPrescriptionOrderTimeCell.swift
//  SmartEyeForPatient
//
//  Created by qdsg on 2021/4/17.
//

import UIKit

protocol SEPrescriptionOrderTimeCellDelegate: NSObjectProtocol {
    func prescriptionOrderTimeCellBtnAction()
}

class SEPrescriptionOrderTimeCell: UITableViewCell {

    static let className = "SEPrescriptionOrderTimeCell"
    static let reuseId = className

    @IBOutlet weak var checkStackViewHeight: NSLayoutConstraint!

    @IBOutlet weak var checkStackView: UIStackView!

    @IBOutlet weak var checkBtn: UIButton! {
        didSet {
            checkBtn.layer.cornerRadius = checkBtn.frame.size.height / 2.0
            checkBtn.layer.borderWidth = 1
            checkBtn.layer.borderColor = Asset.main.color.cgColor
            checkBtn.layer.masksToBounds = true
        }
    }

    @IBAction func checkBtnAction(_ sender: UIButton) {
        delegate?.prescriptionOrderTimeCellBtnAction()
    }

    @IBOutlet weak var orderNumLabel: UILabel!
    @IBOutlet weak var doctorNameLabel: UILabel!
    @IBOutlet weak var auditDoctorNameLabel: UILabel!
    @IBOutlet weak var createTimeLabel: UILabel!
    @IBOutlet weak var updateTimeLabel: UILabel!

    weak var delegate: SEPrescriptionOrderTimeCellDelegate?

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    func updateData(_ viewModel: SEPrescriptionOrderDetailViewModel) {
        orderNumLabel.text = viewModel.model.id
        doctorNameLabel.text = viewModel.model.doctor
        auditDoctorNameLabel.text = viewModel.model.auditor
        createTimeLabel.text = viewModel.model.createTime
        updateTimeLabel.text = viewModel.model.passTime
        checkStackView.isHidden = viewModel.model.orderStatus.isHiddenCheck
        checkStackViewHeight.constant = viewModel.model.orderStatus.isHiddenCheck ? 115 : 140
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
